<?php

namespace App\Admin\Rules;

use App\Admin\Models\WorshipBibleVolume;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Facades\Validator;

class LectionRules implements Rule
{
    protected $invalidRules = [];

    /**
     * Determine if the validation rule passes.
     *
     * @param string $attribute
     * @param mixed $value
     *
     * @return bool
     */
    public function passes($attribute, $value)
    {
        try {
            app(WorshipBibleVolume::class)->lections($value);
        } catch (\Exception $e) {
            return false;
        }
        return true;
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return "经文截取范围格式错误。";
    }
}
